Skip to content

spec: add canary for forgery protection shared context - #2842

Merged
mroderick merged 1 commit into
masterfrom
spec/forgery-protection-canary
Sep 3, 2026
Merged

spec: add canary for forgery protection shared context#2842
mroderick merged 1 commit into
masterfrom
spec/forgery-protection-canary

Conversation

@mroderick

@mroderick mroderick commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

All no-CSRF regression specs depend on one shared-context hook with nothing pinning it works: if the hook stops applying, tokenless requests succeed trivially and the whole regression net passes vacuously. This PR adds a canary example that fails loudly when the toggle breaks.

Key changes:

Why this matters

The shared context's before hook is the only thing enabling forgery protection for the no-CSRF regression specs across four controller spec files. The test environment defaults allow_forgery_protection to false, so if the hook is removed or no-ops, tokenless requests succeed anyway, every regression spec still passes, and the suite silently stops guarding the production skip_forgery_protection lines. Nothing in the suite would detect that: disabling the hook leaves all 41 examples green.

All no-CSRF regression specs depend on the shared context's before hook
enabling ActionController::Base.allow_forgery_protection. If that hook
stops applying, tokenless requests succeed trivially (test environment
defaults the flag to false) and every regression spec still passes, so
the suite would no longer guard the production skip_forgery_protection
lines. One canary example pins the toggle.
@mroderick
mroderick marked this pull request as ready for review September 3, 2026 06:11
@mroderick
mroderick merged commit ebb84d2 into master Sep 3, 2026
9 checks passed
@mroderick
mroderick deleted the spec/forgery-protection-canary branch September 3, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant